home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 8.5 KB | 210 lines | [TEXT/ttxt] |
- --<<<-
- -- Filename:
- -- maketape.sx
- --
- -- Other Files Required:
- -- interfac.sx or interfac.sxl - defines accessory interface module
- -- tape.sx or tape.sxl - defines tape measure classes
- -- mediaimp.sx or mediaimp.sxl - defines media importer classes
- --
- -- Purpose:
- -- Builds an AccessoryContainer for the tape measure tool.
- --
- -- Specialized Classes:
- -- None
- --
- -- Instructions to User:
- -- Run this script to build the tape measure AccessoryContainer.
- -- (Be aware that in ScriptX V1.5, you may not be able to load an
- -- AccessoryContainer into the KMP via simple drag-and-drop because
- -- the "Open" action of the KMP is defined only for TitleContainers.
- -- Use command-Y from a running title to bring up the Open Accessory
- -- menu.)
- --
- -- Author:
- -- Steve Mayer, Ray Davis
- -- Robert Lockstone : 12-15-95 : Convert to 1.5 and modularize
-
- --*=============================================================================*
- --* Get the necessary tape module. Use fileIn in case this whole thing is
- --* getting recompiled with a different version of ScriptX.
- --*=============================================================================*
- fileIn theScriptDir name:"tape.sx"
-
- --*=============================================================================*
- --* Get the library which defines the Tape Measure classes.
- --* This will not open the library if the above fileIn worked.
- --*=============================================================================*
- if ((getModule @TapeInterface) = false) do
- (
- open LibraryContainer dir:(parentDir theScriptDir) \
- path:"tape.sxl" \
- mode:@readable
- )
-
- --*=============================================================================*
- --* Define the interface module to the Tape Measure Implementation
- --*=============================================================================*
- module TapeMeasureInterface
- exports TapeMeasureAccessory
- end
-
- --*=============================================================================*
- --* Define the Tape Measure Implementation module.
- --*=============================================================================*
- module TapeMeasureImplementation
- uses ScriptX
- uses TapeInterface with exports everything end
- uses TapeMeasureInterface with exports everything end
- end
-
- in module TapeMeasureImplementation
-
- global tma
- global mediaImp
- global mediaList
- global mediaDir
- global theStream
- global ringMedia
- global hubMedia
- global hookMedia
- global backgroundMedia
- global textDisp := undefined
- global tm := undefined
-
- class TapeMeasureAccessory (AccessoryContainer)
- instance variables
- accessoryAnswers:(new KeyedLinkedList) --exported by AccessoryInterface module
- end
-
- --*=============================================================================*
- --* Called by a Title (if necessary) to get a Tape Measure and the display
- --* portion which shows the readout.
- --*=============================================================================*
- method getAccessory self {class TapeMeasureAccessory} ->
- (
- return (#(tm, tm.display))
- )
-
- --*=============================================================================*
- --* Import all the necessary media and create the Tape Measure and its display
- --* readout.
- --*=============================================================================*
- mediaList := new KeyedLinkedList
-
- mediaDir := spawn (parentDir theScriptDir) "media"
- theStream := getStream mediaDir "ring.bmp" @readable
- ringMedia := importMedia theImportExportEngine theStream \
- @image \
- @dib \
- @bitmap
- plug theStream
- ringMedia.invisibleColor := whiteColor
-
- theStream := getStream mediaDir "crosshr.bmp" @readable
- hubMedia := importMedia theImportExportEngine theStream \
- @image \
- @dib \
- @bitmap
- plug theStream
- hubMedia.invisibleColor := whiteColor
-
- theStream := getStream mediaDir "tapeball.bmp" @readable
- hookMedia := importMedia theImportExportEngine theStream \
- @image \
- @dib \
- @bitmap
- plug theStream
- hookMedia.matteColor := whiteColor
-
- theStream := getStream mediaDir "tapedisp.bmp" @readable
- backgroundMedia := importMedia theImportExportEngine theStream \
- @image \
- @dib \
- @bitmap
- plug theStream
- backgroundMedia.matteColor := whiteColor
-
- --*=============================================================================*
- --* Create TwoDShapes to hold the media and add them to the media list.
- --*=============================================================================*
- add mediaList @ring (new TwoDShape boundary:ringMedia)
- add mediaList @hub (new TwoDShape boundary:hubMedia)
- add mediaList @hook (new TwoDShape boundary:hookMedia)
- add mediaList @background (new TwoDShape boundary:backgroundMedia)
-
- mediaList[@hub].position := new Point x:23 y:21 --Position the hub shape.
-
- textDisp := new TextDisplay media:mediaList
- tm := new TapeMeasure media:mediaList display:textDisp
- tm.position := new Point x:40 y:50
-
- --*=============================================================================*
- --* Create the tape measure accessory container and store the tape measure.
- --*=============================================================================*
- tma := new TapeMeasureAccessory dir:(parentDir theScriptDir) \
- path:"tape.sxa" \
- mode:@create
- tma.name := "Tape Measure Object"
- tma.startupAction :=
- (
- tapeTMA ->
- (
- --*=======================================================================*
- --* Load the interface and implementation modules.
- --*=======================================================================*
- forEach tapeTMA \
- (
- aModule xx ->
- (
- load aModule
- )
- ) undefined
-
- --*=======================================================================*
- --* Be a smart accessory and try to find a title to add yourself to.
- --*=======================================================================*
- for realTC in theOpenTitles do
- (
- if (isAppropriateAccessory realTC tapeTMA) do
- (
- --*=================================================================*
- --* Unfortunately, isAppropriateAccessory defaults to returning
- --* 'true'. So every Title will say "Sure! Go ahead and add me!"
- --* But I don't want that. So I have to put an additional check in
- --* here to make sure the title is using my accessory interface.
- --* I think isAppropriateAccessory should default to returning
- --* 'false'.
- --*=================================================================*
- if (isDefined currentSceneGetter) and \
- (canObjectDo realTC currentSceneGetter) do
- (
- tm.foundHome := false --Make sure we can be added again.
- tm.scale := #(#("pixels", 1)) --Reset scale between scenes
- addAccessory realTC tapeTMA
- addToTitle tm realTC pres:realTC.currentScene
- )
- )
- )
- )
- )
-
- --*=============================================================================*
- --* Provide answers to the questions a title, e.g. AutoFinder, may want to know.
- --* These are just examples, AutoFinder only uses questions 1 and 2.
- --*=============================================================================*
- add tma.accessoryAnswers @question1 @yes --Do you want to add yourself to me?
- add tma.accessoryAnswers @question2 @yes --Do you inherit from TwoDPresenter?
- add tma.accessoryAnswers @question3 @yes --Can you be removed between scene changes?
- add tma.accessoryAnswers @question4 #() --What is your cleanup method?
-
- append tma (getModule @TapeMeasureInterface)
- append tma (getModule @TapeMeasureImplementation)
-
- addUser (getStorageContainer (getModule @TapeInterface)) tma
-
- close tma
-
- "Compiled maketape.sx"
-
- -->>>